package controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import pojo.Customer;
import service.CustomerManager;
@RestController
public class CustomerController {
	@Resource(name="manager")
	private CustomerManager manager;
	public CustomerController() {
		
	}
	
	@RequestMapping(value="/addCustomer",method=RequestMethod.POST,consumes="application/json")
	public Customer addCustomer(@RequestBody Customer c){
		return manager.addCustomer(c);
	}
	@RequestMapping(value="/updateCustomer",method=RequestMethod.PUT,consumes="application/json")
	public Customer updateCustomer(@RequestBody Customer c){
		System.out.println("update");
		return manager.updateCustomer(c);
	}
	@RequestMapping(value="/deleteCustomer",method=RequestMethod.DELETE)
	public String deleteCustomer(String id){
		return manager.deleteCustomer(id);
	}
	@RequestMapping(value="/findAllCustomers",method=RequestMethod.GET)
	public List<Customer> findAllCustomers(){
		return manager.findAllCustomers();
	}
	
}





